/**
 * Created by Administrator on 2016-12-09.
 */
!function ($) {
    var FASTMC={
        WEB_ROOT:'/',
        IS_DEBUG   : false,
        debug: function(msg) {
            if (this.IS_DEBUG) {
                if (typeof(console) != 'undefined') console.log(msg)
                else alert(msg)
            }
        },
        init: function(options) {
            var op = $.extend({}, options)
            if (op.JSPATH) this.JSPATH = op.JSPATH

        },
        initLayout: function(ww) {
            var iContentW = ww - $('#main-sidebar').width() + 6 ,
                iContentH = $(window).height() - $('#main-header').height() - $('#main-footer').outerHeight(),
                navtabH   = $('#main-navtab').find('.tabsPageHeader').height()


            FASTMC.windowWidth = ww

            $('#main-container').height(iContentH)
            $('#main-navtab').width(iContentW)
            $('#main-leftside, #main-sidebar, #main-sidebar-s, #main-splitBar, #main-splitBarProxy').css({height:'100%'})
            $('#main-navtab .tabsPageContent').height(iContentH - navtabH)

            /* header navbar */
            var navbarWidth = $('body').data('main.navbar.width'),
                $header = $('#main-header'), $toggle = $header.find('.main-navbar-toggle'), $logo = $header.find('.main-navbar-logo'), $navbar = $('#main-navbar-collapse'), $nav = $navbar.find('.main-navbar-right')

            if (!navbarWidth) {
                navbarWidth = {logoW:$logo.outerWidth(), navW:$nav.outerWidth()}
                $('body').data('main.navbar.width', navbarWidth)
            }
            if (navbarWidth) {
                if (ww - navbarWidth.logoW < navbarWidth.navW) {
                    $toggle.show()
                    $navbar.addClass('collapse menu')
                } else {
                    $toggle.hide()
                    $navbar.removeClass('collapse menu in')
                }
            }
            /* horizontal navbar */
            var $hnavbox  = $('#main-hnav-navbar-box'),
                $hnavbar  = $hnavbox.find('> #main-hnav-navbar'),
                $hmoreL   = $hnavbox.prev(),
                $hmoreR   = $hnavbox.next(),
                hboxWidth = $hnavbox.width(),
                liW       = 0

            $hnavbar.find('> li').each(function(i) {
                var $li = $(this)

                liW += $li.outerWidth()

                if (liW > hboxWidth) {
                    $hmoreR.show()
                    $hnavbox.data('hnav.move', true).data('hnav.liw', liW)
                } else {
                    $hmoreL.hide()
                    $hmoreR.hide()
                    $hnavbox.removeData('hnav.move')
                }
            })
        }

    }
}
